﻿namespace Utility1
{
    using System;

    public class StringUtil
    {
        private static readonly string[] VietnameseSigns = new string[] { "aAeEoOuUiIdDyY", "\x00e1\x00e0ạả\x00e3\x00e2ấầậẩẫăắằặẳẵ", "\x00c1\x00c0ẠẢ\x00c3\x00c2ẤẦẬẨẪĂẮẰẶẲẴ", "\x00e9\x00e8ẹẻẽ\x00eaếềệểễ", "\x00c9\x00c8ẸẺẼ\x00caẾỀỆỂỄ", "\x00f3\x00f2ọỏ\x00f5\x00f4ốồộổỗơớờợởỡ", "\x00d3\x00d2ỌỎ\x00d5\x00d4ỐỒỘỔỖƠỚỜỢỞỠ", "\x00fa\x00f9ụủũưứừựửữ", "\x00da\x00d9ỤỦŨƯỨỪỰỬỮ", "\x00ed\x00ecịỉĩ", "\x00cd\x00ccỊỈĨ", "đ", "Đ", "\x00fdỳỵỷỹ", "\x00ddỲỴỶỸ" };

        public static string ConvertIntToStringVietNam(int i)
        {
            switch (i)
            {
                case 1:
                    return "Một";

                case 2:
                    return "Hai";

                case 3:
                    return "Ba";

                case 4:
                    return "Bốn";

                case 5:
                    return "Năm";

                case 6:
                    return "S\x00e1u";

                case 7:
                    return "Bảy";

                case 8:
                    return "T\x00e1m";

                case 9:
                    return "Ch\x00edn";

                case 10:
                    return "Mười";

                case 11:
                    return "Mười Một";

                case 12:
                    return "Mười Hai";
            }
            return "";
        }

        public static string RemoveSign4VietnameseString(string str)
        {
            for (int i = 1; i < VietnameseSigns.Length; i++)
            {
                for (int j = 0; j < VietnameseSigns[i].Length; j++)
                {
                    str = str.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]);
                }
            }
            return str;
        }

        public static string RemoveSign4VietnameseStringAndSpace(string str)
        {
            string oldValue = "";
            return RemoveSign4VietnameseString(str).Replace(" ", "-").Replace(":", "").Replace(";", "").Replace(",", "").Replace(".", "").Replace("&", "").Replace("/", "").Replace("'", "").Replace("!", "").Replace("“", "").Replace("”", "").Replace(oldValue, "").Replace("--", "").Replace("---", "");
        }
    }
}

